package cn.java79.quiz.service;

import cn.java79.quiz.dao.AdminMapper;
import cn.java79.quiz.dao.SectioninfoMapper;
import cn.java79.quiz.entity.Admin;
import cn.java79.quiz.entity.Sectioninfo;
import cn.java79.quiz.pojo.Section;
import cn.java79.quiz.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * @author oldliu
 * @since 1.0
 */
public class SectionService {
    public static SectionService ME=new SectionService();

    public int delete(Long id){
        SqlSession s = MybatisUtil.get();
        try {
            SectioninfoMapper mapper = s.getMapper(SectioninfoMapper.class);
            return  mapper.delete(id);
        }finally {
            MybatisUtil.close(s);
        }
    }

    public int insert(Sectioninfo record){
        SqlSession s = MybatisUtil.get();
        try {
            SectioninfoMapper mapper = s.getMapper(SectioninfoMapper.class);
            return  mapper.insert(record);
        }finally {
            MybatisUtil.close(s);
        }
    }


    public Sectioninfo get(Long id){
        SqlSession s = MybatisUtil.get();
        try {
            SectioninfoMapper mapper = s.getMapper(SectioninfoMapper.class);
            return  mapper.get(id);
        }finally {
            MybatisUtil.close(s);
        }
    }

    public int update(Sectioninfo record){
        SqlSession s = MybatisUtil.get();
        try {
            SectioninfoMapper mapper = s.getMapper(SectioninfoMapper.class);
            return  mapper.update(record);
        }finally {
            MybatisUtil.close(s);
        }
    }

    public List<Section> findTop(){
        SqlSession s = MybatisUtil.get();
        try {
            SectioninfoMapper mapper = s.getMapper(SectioninfoMapper.class);
            return  mapper.findTop();
        }finally {
            MybatisUtil.close(s);
        }
    }



}
